<template>
    <a-modal
        :title="'查阅政策法规'"
        :visible="isShowModal"
        width="80%"
        :footer="null"
        dialogClass="custom-modal"
        @cancel="handleCancel"
        :maskClosable="false"
    >
        <div class="policy_title">
            {{ form.name }}
        </div>
        <div class="infos">
            <div>发布时间：{{ $moment(form.releaseDateTime).format('YYYY-MM-DD') }}</div>
            <div>发布单位：{{ form.releaseUnit }}</div>
        </div>
        <div class="hr"></div>
        <div class="body" v-html="form.content"></div>
    </a-modal>
</template>
<script>
export default {
    data() {
        return {
            confirmLoading: false,
            form: {
                content: '',
                name: '',
                releaseDateTime: null,
                releaseUnit: '',
                type: '',
                infos: [],
            },
        }
    },
    components: {},
    props: {
        isShowModal: {
            required: true,
            type: Boolean,
        },
        currRow: {
            required: false,
            type: [Object, undefined],
        },
        enterpriseId: {
            required: true,
            type: String,
        },
    },
    watch: {
        isShowModal: {
            immediate: true,
            handler: function (isShowModal) {
                if (isShowModal) {
                    this.beforeShowModal()
                } else {
                    this.$refs.form && this.$refs.form.resetFields()
                }
            },
        },
    },
    beforeDestroy() {
        this.$refs.form && this.$refs.form.resetFields()
    },
    methods: {
        beforeShowModal() {
            if (this.currRow) {
                const { content, name, releaseDateTime, releaseUnit, type } = this.currRow
                Object.assign(this.form, {
                    content,
                    name,
                    releaseDateTime,
                    releaseUnit,
                    type,
                })
            }
        },
        handleCancel() {
            this.$emit('update:isShowModal', false)
        },
    },
}
</script>
<style scoped lang="scss">
.policy_title {
    font-size: 32px;
    font-family: Alibaba-PuHuiTi-M, Alibaba-PuHuiTi;
    font-weight: normal;
    color: #243144;
    line-height: 40px;
    text-align: center;
}
.infos {
    display: flex;
    font-size: 14px;
    font-family: Alibaba-PuHuiTi-R, Alibaba-PuHuiTi;
    font-weight: normal;
    color: rgba(36, 49, 68, 0.8);
    line-height: 22px;
    margin-top: 16px;

    div {
        margin-right: 32px;
    }
}
.hr {
    height: 1px;
    background: #d5d8de;
    margin: 16px 0 24px 0;
}
.body {
    font-size: 14px;
    font-family: Alibaba-PuHuiTi-R, Alibaba-PuHuiTi;
    font-weight: normal;
    color: #243144;
    line-height: 22px;
}
</style>
